package com.kyzh.core.dialog

import android.annotation.SuppressLint
import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.databinding.DataBindingUtil
import com.kyzh.core.R
import com.kyzh.core.databinding.DialogDescBinding


private var descDialog:AlertDialog?=null

fun Activity.showDescDialog(title: String,content:String,listener:()->Unit){
    descDialog = AlertDialog.Builder(this, R.style.kyzhGuestLoginDialog)
            .setView(getView(title,content,listener))
            .create()

    descDialog?.show()
}
@SuppressLint("ClickableViewAccessibility")
private fun Activity.getView(title: String, content: String,listener:()->Unit):View{
    val binding = DataBindingUtil.inflate<DialogDescBinding>(LayoutInflater.from(this),R.layout.dialog_desc,null,false)
    binding.tvTitle.text = title
    binding.tvContent.text = content
    binding.btSure.setOnClickListener {
        listener()
        descDialog?.dismiss()
    }
    return binding.root
}